﻿USE [ESRP]
GO

/****** Object:  Table [dbo].[ArticoleParteneri]    Script Date: 03/03/2010 14:37:27 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[ArticoleParteneri](
	[IDArticol] [int] NOT NULL,
	[IDPartener] [bigint] NOT NULL,
	[CodArticol] [varchar](50) NOT NULL,
 CONSTRAINT [PK_ArticoleParteneri] PRIMARY KEY CLUSTERED 
(
	[IDArticol] ASC,
	[IDPartener] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[ArticoleParteneri]  WITH CHECK ADD  CONSTRAINT [FK_ArticoleParteneri_Articole] FOREIGN KEY([IDArticol])
REFERENCES [dbo].[Articole] ([IDArticol])
GO

ALTER TABLE [dbo].[ArticoleParteneri] CHECK CONSTRAINT [FK_ArticoleParteneri_Articole]
GO

ALTER TABLE [dbo].[ArticoleParteneri]  WITH CHECK ADD  CONSTRAINT [FK_ArticoleParteneri_Parteneri] FOREIGN KEY([IDPartener])
REFERENCES [dbo].[Parteneri] ([IDPartener])
GO

ALTER TABLE [dbo].[ArticoleParteneri] CHECK CONSTRAINT [FK_ArticoleParteneri_Parteneri]
GO

USE [ESRP]
GO

/****** Object:  Table [dbo].[Articole]    Script Date: 03/03/2010 15:17:49 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Articole](
	[IDArticol] [int] IDENTITY(1,1) NOT NULL,
	[CodArticol] [varchar](50) NOT NULL,
	[Denumire] [varchar](100) NOT NULL,
	[IDCategorie] [smallint] NOT NULL,
	[CodUnitate] [smallint] NOT NULL,
	[IDUnitateMasura] [smallint] NOT NULL,
	[Cont] [dbo].[TipCont] NOT NULL,
	[ContCheltuiala] [dbo].[TipCont] NOT NULL,
	[Greutate] [float] NOT NULL,
	[CodCPV] [nvarchar](12) NULL,
 CONSTRAINT [PK_Articole] PRIMARY KEY CLUSTERED 
(
	[IDArticol] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [IX_CodArticolUnitate] UNIQUE NONCLUSTERED 
(
	[CodArticol] ASC,
	[CodUnitate] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[Articole]  WITH CHECK ADD  CONSTRAINT [FK_Articole_CategoriiArticole] FOREIGN KEY([IDCategorie])
REFERENCES [dbo].[TipCategoriiArticole] ([IDCategorie])
GO

ALTER TABLE [dbo].[Articole] CHECK CONSTRAINT [FK_Articole_CategoriiArticole]
GO

ALTER TABLE [dbo].[Articole]  WITH CHECK ADD  CONSTRAINT [FK_Articole_Conturi] FOREIGN KEY([Cont], [CodUnitate])
REFERENCES [dbo].[Conturi] ([Cont], [CodUnitate])
GO

ALTER TABLE [dbo].[Articole] CHECK CONSTRAINT [FK_Articole_Conturi]
GO

ALTER TABLE [dbo].[Articole]  WITH CHECK ADD  CONSTRAINT [FK_Articole_ConturiCheltuiala] FOREIGN KEY([ContCheltuiala], [CodUnitate])
REFERENCES [dbo].[Conturi] ([Cont], [CodUnitate])
GO

ALTER TABLE [dbo].[Articole] CHECK CONSTRAINT [FK_Articole_ConturiCheltuiala]
GO

ALTER TABLE [dbo].[Articole]  WITH CHECK ADD  CONSTRAINT [FK_Articole_CPV] FOREIGN KEY([CodCPV])
REFERENCES [dbo].[CPV] ([Cod])
GO

ALTER TABLE [dbo].[Articole] CHECK CONSTRAINT [FK_Articole_CPV]
GO

ALTER TABLE [dbo].[Articole]  WITH CHECK ADD  CONSTRAINT [FK_Articole_Unitati] FOREIGN KEY([CodUnitate])
REFERENCES [dbo].[Unitati] ([CodUnitate])
GO

ALTER TABLE [dbo].[Articole] CHECK CONSTRAINT [FK_Articole_Unitati]
GO

ALTER TABLE [dbo].[Articole]  WITH CHECK ADD  CONSTRAINT [FK_Articole_UnitatiMasura] FOREIGN KEY([IDUnitateMasura])
REFERENCES [dbo].[UnitatiMasura] ([IDUnitateMasura])
GO

ALTER TABLE [dbo].[Articole] CHECK CONSTRAINT [FK_Articole_UnitatiMasura]
GO

ALTER TABLE [dbo].[Articole] ADD  CONSTRAINT [DF_Articole_CodArticol]  DEFAULT ('') FOR [CodArticol]
GO

ALTER TABLE [dbo].[Articole] ADD  CONSTRAINT [DF_Articole_Cont]  DEFAULT ('N/A') FOR [Cont]
GO

ALTER TABLE [dbo].[Articole] ADD  CONSTRAINT [DF_Articole_ContCheltuiala]  DEFAULT ('N/A') FOR [ContCheltuiala]
GO

ALTER TABLE [dbo].[Articole] ADD  CONSTRAINT [DF_Articole_Greutate]  DEFAULT ((0)) FOR [Greutate]
GO


